/**
 * 
 */
package com.lemote.rest.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lemote.entity.User;
import com.lemote.resp.RespCode;
import com.lemote.resp.UserResp;
import com.lemote.rest.UserRest;
import com.lemote.service.UserService;

/**
 * @author wuhui
 *
 * 下午05:31:35
 */
@Component("userRest")
public class UserRestImpl implements UserRest {

	private UserService userService;
	
	@Override
	public UserResp getUserById(Long id) {
		UserResp resp = new UserResp();
		try {
			User user = userService.get(id);
			if (user!=null) {
				resp.setUser(user);
				resp.setCode(RespCode.PASS_OK);
			}else {
				resp.setCode(RespCode.PASS_NODATA);
			}
		} catch (Exception e) {
			resp.setCode(RespCode.EX_APP);
			e.printStackTrace();
		}
		return resp;
	}

	@Autowired
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	

}
